<?php

// 文本自动换行

// 需要实现字符串自动换行，例如使用 <pre>和</pre> 标记显示文本
// 单要求保持在一个常规大小的浏览器窗口以内

// 解决方案  wordwrap()

$string = "four score and seven years age our fathers brought forth on this continent a new nation ,conceived in liberty and dedicated to the proposition
that all men are created equal.";

//print wordwrap($string, 50);
// 结果 自动按 每50个字符换行
/*
four score and seven years age our fathers brought
forth on this continent a new nation ,conceived in
liberty and dedicated to the proposition
that all men are created equal.
*/

// 还可自动换行符
//print wordwrap($string, 50,"\r\t");

// 第四个参数 用来控制如何处理超出指定行长度的单词
// 如果是 1 ，会对这些超出行长度的单词自动换行，否则，就会越过指定的行长度而保留源字符串

//print wordwrap('jabberwocks',5);//jabberwocksjabbe

print wordwrap('jabberwocks',5,"\n",1);
//jabbe
//rwock
//s